{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1fec0b14",
   "metadata": {
    "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
    "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:04.163756Z",
     "iopub.status.busy": "2025-07-15T05:12:04.163453Z",
     "iopub.status.idle": "2025-07-15T05:12:21.464554Z",
     "shell.execute_reply": "2025-07-15T05:12:21.463577Z"
    },
    "papermill": {
     "duration": 17.308112,
     "end_time": "2025-07-15T05:12:21.466200",
     "exception": false,
     "start_time": "2025-07-15T05:12:04.158088",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-07-15 05:12:05.904456: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
      "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
      "E0000 00:00:1752556326.114093      19 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
      "E0000 00:00:1752556326.172639      19 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.keras import layers, models\n",
    "import numpy as np\n",
    "import os\n",
    "from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard, EarlyStopping\n",
    "from tensorflow.keras.regularizers import l2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6e70d1cd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:21.472957Z",
     "iopub.status.busy": "2025-07-15T05:12:21.472230Z",
     "iopub.status.idle": "2025-07-15T05:12:21.480994Z",
     "shell.execute_reply": "2025-07-15T05:12:21.480171Z"
    },
    "papermill": {
     "duration": 0.013459,
     "end_time": "2025-07-15T05:12:21.482427",
     "exception": false,
     "start_time": "2025-07-15T05:12:21.468968",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def build_model(input_shape, num_class):\n",
    "    inputs = layers.Input(shape=input_shape)\n",
    "    \n",
    "    x = layers.LSTM(64, return_sequences=True, kernel_regularizer=l2(1e-4))(inputs)\n",
    "    x = layers.Dropout(0.3)(x)\n",
    "    x = layers.LSTM(64, return_sequences=True, kernel_regularizer=l2(1e-4))(x)\n",
    "    x = layers.Dropout(0.3)(x)\n",
    "    \n",
    "    x = layers.Conv1D(filters=128, kernel_size=5, strides=2, activation='relu', padding='same',\n",
    "               kernel_regularizer=l2(1e-4))(x)\n",
    "    x = layers.BatchNormalization()(x)\n",
    "    x = layers.Dropout(0.3)(x)\n",
    "    \n",
    "    x = layers.MaxPooling1D(pool_size=2, strides=2, padding='same')(x)\n",
    "    \n",
    "    x = layers.Conv1D(filters=256, kernel_size=3, strides=1, activation='relu', padding='same',\n",
    "               kernel_regularizer=l2(1e-4))(x)\n",
    "    x = layers.BatchNormalization()(x)\n",
    "    x = layers.Dropout(0.3)(x)\n",
    "    \n",
    "    x = layers.Conv1D(filters=256, kernel_size=3, strides=1, activation='relu', padding='same',\n",
    "               kernel_regularizer=l2(1e-4))(x)\n",
    "    x = layers.BatchNormalization()(x)\n",
    "    x = layers.Dropout(0.3)(x)\n",
    "    \n",
    "    x = layers.GlobalAveragePooling1D()(x)\n",
    "    \n",
    "    x = layers.BatchNormalization()(x)\n",
    "    x = layers.Dropout(0.5)(x)\n",
    "    \n",
    "    x = layers.Dense(128, activation='relu', kernel_regularizer=l2(1e-4))(x)\n",
    "    x = layers.Dropout(0.5)(x)\n",
    "    \n",
    "    outputs = layers.Dense(units=num_class, activation='softmax')(x)\n",
    "    \n",
    "    model = models.Model(inputs=inputs, outputs=outputs)\n",
    "    return model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a04fcc44",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:21.488024Z",
     "iopub.status.busy": "2025-07-15T05:12:21.487781Z",
     "iopub.status.idle": "2025-07-15T05:12:21.496979Z",
     "shell.execute_reply": "2025-07-15T05:12:21.496011Z"
    },
    "papermill": {
     "duration": 0.013378,
     "end_time": "2025-07-15T05:12:21.498267",
     "exception": false,
     "start_time": "2025-07-15T05:12:21.484889",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def read_dataset(path: str, train: bool=True, is_static=None) -> tuple[np.ndarray, np.ndarray]:\n",
    "    label = \"train\" if train else \"test\"\n",
    "    acc_x = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_acc_x_{label}.txt\"), dtype=np.float32)\n",
    "    acc_y = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_acc_y_{label}.txt\"), dtype=np.float32)\n",
    "    acc_z = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_acc_z_{label}.txt\"), dtype=np.float32)\n",
    "    gyro_x = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_gyro_x_{label}.txt\"), dtype=np.float32)\n",
    "    gyro_y = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_gyro_y_{label}.txt\"), dtype=np.float32)\n",
    "    gyro_z = np.loadtxt(os.path.join(path, label, \"Inertial Signals\", f\"body_gyro_z_{label}.txt\"), dtype=np.float32)\n",
    "    assert acc_x.shape[0] == acc_y.shape[0] and acc_x.shape[0] == acc_z.shape[0] and acc_x.shape[0] == gyro_x.shape[0] and acc_x.shape[0] == gyro_y.shape[0] and acc_x.shape[0] == gyro_z.shape[0], \"All arrays must have the same length.\"\n",
    "    \n",
    "    X = np.stack((acc_x, acc_y, acc_z, gyro_x, gyro_y, gyro_z), axis=2)\n",
    "    y = np.loadtxt(os.path.join(path, label, f\"y_{label}.txt\"), dtype=np.int32) - 1\n",
    "    assert X.shape[0] == y.shape[0], \"The number of samples in X and y must be the same.\"\n",
    "\n",
    "    mean = np.array([-0.00066533, -0.00031751, -0.00020395, -0.0034113 , -0.00017161, 0.00089603], dtype=np.float32)\n",
    "    std = np.array([0.14196804, 0.08511718, 0.07230477, 0.26109824, 0.27211866, 0.17970076], dtype=np.float32)\n",
    "    X = (X - mean) / std\n",
    "\n",
    "    if is_static is not None:\n",
    "        if is_static:\n",
    "            filters = y > 2\n",
    "        else:\n",
    "            filters = y <= 2\n",
    "        X = X[filters]\n",
    "        y = y[filters]\n",
    "    return X, y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a55d4635",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:21.503838Z",
     "iopub.status.busy": "2025-07-15T05:12:21.503540Z",
     "iopub.status.idle": "2025-07-15T05:12:21.508021Z",
     "shell.execute_reply": "2025-07-15T05:12:21.507464Z"
    },
    "papermill": {
     "duration": 0.008744,
     "end_time": "2025-07-15T05:12:21.509277",
     "exception": false,
     "start_time": "2025-07-15T05:12:21.500533",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def create_callbacks(log_dir: str, checkpoint_path: str) -> [tf.keras.callbacks.Callback]:\n",
    "    tensorboard_callback = TensorBoard(\n",
    "        log_dir=log_dir,\n",
    "        histogram_freq=1,\n",
    "        write_graph=True,\n",
    "        write_images=True\n",
    "    )\n",
    "\n",
    "    checkpoint_callback = ModelCheckpoint(\n",
    "        filepath=checkpoint_path,\n",
    "        monitor='val_accuracy',\n",
    "        save_best_only=True,\n",
    "        mode='max',\n",
    "        verbose=1\n",
    "    )\n",
    "\n",
    "    early_stopping_callback = EarlyStopping(\n",
    "        monitor='val_loss',\n",
    "        patience=50,\n",
    "        restore_best_weights=True,\n",
    "        verbose=1\n",
    "    )\n",
    "\n",
    "    return [tensorboard_callback, checkpoint_callback, early_stopping_callback]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "88c0f4b2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:21.514864Z",
     "iopub.status.busy": "2025-07-15T05:12:21.514580Z",
     "iopub.status.idle": "2025-07-15T05:12:23.822229Z",
     "shell.execute_reply": "2025-07-15T05:12:23.821608Z"
    },
    "papermill": {
     "duration": 2.311888,
     "end_time": "2025-07-15T05:12:23.823536",
     "exception": false,
     "start_time": "2025-07-15T05:12:21.511648",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(7352, 128, 6) (7352,) (2947, 128, 6) (2947,)\n"
     ]
    }
   ],
   "source": [
    "X_train, y_train = read_dataset(\"/kaggle/input/ucihar-dataset/UCI-HAR Dataset\", train=True)\n",
    "X_test, y_test = read_dataset(\"/kaggle/input/ucihar-dataset/UCI-HAR Dataset\", train=False)\n",
    "print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5f17826f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:23.829445Z",
     "iopub.status.busy": "2025-07-15T05:12:23.829163Z",
     "iopub.status.idle": "2025-07-15T05:12:24.784049Z",
     "shell.execute_reply": "2025-07-15T05:12:24.782911Z"
    },
    "papermill": {
     "duration": 0.959884,
     "end_time": "2025-07-15T05:12:24.785858",
     "exception": false,
     "start_time": "2025-07-15T05:12:23.825974",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "I0000 00:00:1752556344.688929      19 gpu_device.cc:2022] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 15513 MB memory:  -> device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0\n"
     ]
    }
   ],
   "source": [
    "batch_size = 32\n",
    "\n",
    "train_dataset = tf.data.Dataset.from_tensor_slices((X_train, y_train)).batch(batch_size).shuffle(1000).prefetch(tf.data.AUTOTUNE)\n",
    "val_dataset = tf.data.Dataset.from_tensor_slices((X_test, y_test)).batch(batch_size).prefetch(tf.data.AUTOTUNE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "993ac360",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:24.792311Z",
     "iopub.status.busy": "2025-07-15T05:12:24.791841Z",
     "iopub.status.idle": "2025-07-15T05:12:26.433041Z",
     "shell.execute_reply": "2025-07-15T05:12:26.432299Z"
    },
    "papermill": {
     "duration": 1.645794,
     "end_time": "2025-07-15T05:12:26.434332",
     "exception": false,
     "start_time": "2025-07-15T05:12:24.788538",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.11/dist-packages/keras/src/trainers/trainer.py:212: UserWarning: Model doesn't support `jit_compile=True`. Proceeding with `jit_compile=False`.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">Model: \"functional\"</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1mModel: \"functional\"\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
       "┃<span style=\"font-weight: bold\"> Layer (type)                    </span>┃<span style=\"font-weight: bold\"> Output Shape           </span>┃<span style=\"font-weight: bold\">       Param # </span>┃\n",
       "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
       "│ input_layer (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">InputLayer</span>)        │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">6</span>)         │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ lstm (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">LSTM</span>)                     │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>)        │        <span style=\"color: #00af00; text-decoration-color: #00af00\">18,176</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)               │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ lstm_1 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">LSTM</span>)                   │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>)        │        <span style=\"color: #00af00; text-decoration-color: #00af00\">33,024</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_1 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Conv1D</span>)                 │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)        │        <span style=\"color: #00af00; text-decoration-color: #00af00\">41,088</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)        │           <span style=\"color: #00af00; text-decoration-color: #00af00\">512</span> │\n",
       "│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">BatchNormalization</span>)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_2 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">64</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ max_pooling1d (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">MaxPooling1D</span>)    │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d_1 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Conv1D</span>)               │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │        <span style=\"color: #00af00; text-decoration-color: #00af00\">98,560</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_1           │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │         <span style=\"color: #00af00; text-decoration-color: #00af00\">1,024</span> │\n",
       "│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">BatchNormalization</span>)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_3 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d_2 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Conv1D</span>)               │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │       <span style=\"color: #00af00; text-decoration-color: #00af00\">196,864</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_2           │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │         <span style=\"color: #00af00; text-decoration-color: #00af00\">1,024</span> │\n",
       "│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">BatchNormalization</span>)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_4 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">32</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)        │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ global_average_pooling1d        │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)            │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">GlobalAveragePooling1D</span>)        │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_3           │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)            │         <span style=\"color: #00af00; text-decoration-color: #00af00\">1,024</span> │\n",
       "│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">BatchNormalization</span>)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_5 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">256</span>)            │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>)                   │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)            │        <span style=\"color: #00af00; text-decoration-color: #00af00\">32,896</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_6 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>)             │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>)            │             <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense_1 (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>)                 │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">6</span>)              │           <span style=\"color: #00af00; text-decoration-color: #00af00\">774</span> │\n",
       "└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
       "</pre>\n"
      ],
      "text/plain": [
       "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
       "┃\u001b[1m \u001b[0m\u001b[1mLayer (type)                   \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape          \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m      Param #\u001b[0m\u001b[1m \u001b[0m┃\n",
       "┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
       "│ input_layer (\u001b[38;5;33mInputLayer\u001b[0m)        │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m, \u001b[38;5;34m6\u001b[0m)         │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ lstm (\u001b[38;5;33mLSTM\u001b[0m)                     │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m, \u001b[38;5;34m64\u001b[0m)        │        \u001b[38;5;34m18,176\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout (\u001b[38;5;33mDropout\u001b[0m)               │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m, \u001b[38;5;34m64\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ lstm_1 (\u001b[38;5;33mLSTM\u001b[0m)                   │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m, \u001b[38;5;34m64\u001b[0m)        │        \u001b[38;5;34m33,024\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_1 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m, \u001b[38;5;34m64\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d (\u001b[38;5;33mConv1D\u001b[0m)                 │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m64\u001b[0m, \u001b[38;5;34m128\u001b[0m)        │        \u001b[38;5;34m41,088\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m64\u001b[0m, \u001b[38;5;34m128\u001b[0m)        │           \u001b[38;5;34m512\u001b[0m │\n",
       "│ (\u001b[38;5;33mBatchNormalization\u001b[0m)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_2 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m64\u001b[0m, \u001b[38;5;34m128\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ max_pooling1d (\u001b[38;5;33mMaxPooling1D\u001b[0m)    │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m128\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d_1 (\u001b[38;5;33mConv1D\u001b[0m)               │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │        \u001b[38;5;34m98,560\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_1           │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │         \u001b[38;5;34m1,024\u001b[0m │\n",
       "│ (\u001b[38;5;33mBatchNormalization\u001b[0m)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_3 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ conv1d_2 (\u001b[38;5;33mConv1D\u001b[0m)               │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │       \u001b[38;5;34m196,864\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_2           │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │         \u001b[38;5;34m1,024\u001b[0m │\n",
       "│ (\u001b[38;5;33mBatchNormalization\u001b[0m)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_4 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m32\u001b[0m, \u001b[38;5;34m256\u001b[0m)        │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ global_average_pooling1d        │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m256\u001b[0m)            │             \u001b[38;5;34m0\u001b[0m │\n",
       "│ (\u001b[38;5;33mGlobalAveragePooling1D\u001b[0m)        │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ batch_normalization_3           │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m256\u001b[0m)            │         \u001b[38;5;34m1,024\u001b[0m │\n",
       "│ (\u001b[38;5;33mBatchNormalization\u001b[0m)            │                        │               │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_5 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m256\u001b[0m)            │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense (\u001b[38;5;33mDense\u001b[0m)                   │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m)            │        \u001b[38;5;34m32,896\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dropout_6 (\u001b[38;5;33mDropout\u001b[0m)             │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m)            │             \u001b[38;5;34m0\u001b[0m │\n",
       "├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
       "│ dense_1 (\u001b[38;5;33mDense\u001b[0m)                 │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m6\u001b[0m)              │           \u001b[38;5;34m774\u001b[0m │\n",
       "└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Total params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">424,966</span> (1.62 MB)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m Total params: \u001b[0m\u001b[38;5;34m424,966\u001b[0m (1.62 MB)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">423,174</span> (1.61 MB)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m Trainable params: \u001b[0m\u001b[38;5;34m423,174\u001b[0m (1.61 MB)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Non-trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">1,792</span> (7.00 KB)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1m Non-trainable params: \u001b[0m\u001b[38;5;34m1,792\u001b[0m (7.00 KB)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "model = build_model(input_shape=(128, 6), num_class=6)\n",
    "\n",
    "model.compile(optimizer='adam',\n",
    "            loss='sparse_categorical_crossentropy',\n",
    "            metrics=['accuracy'],\n",
    "            jit_compile=True)\n",
    "\n",
    "model.build(input_shape=(None, 128, 6))\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7b2fffda",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:12:26.442143Z",
     "iopub.status.busy": "2025-07-15T05:12:26.441326Z",
     "iopub.status.idle": "2025-07-15T05:20:31.687980Z",
     "shell.execute_reply": "2025-07-15T05:20:31.687117Z"
    },
    "papermill": {
     "duration": 485.251567,
     "end_time": "2025-07-15T05:20:31.689279",
     "exception": false,
     "start_time": "2025-07-15T05:12:26.437712",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/1000\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "I0000 00:00:1752556355.837147      57 cuda_dnn.cc:529] Loaded cuDNN version 90300\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 23ms/step - accuracy: 0.3315 - loss: 2.3401\n",
      "Epoch 1: val_accuracy improved from -inf to 0.21581, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m20s\u001b[0m 33ms/step - accuracy: 0.3321 - loss: 2.3368 - val_accuracy: 0.2158 - val_loss: 1.8826\n",
      "Epoch 2/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.4962 - loss: 1.4290\n",
      "Epoch 2: val_accuracy improved from 0.21581 to 0.63929, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.4965 - loss: 1.4280 - val_accuracy: 0.6393 - val_loss: 1.2538\n",
      "Epoch 3/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.6108 - loss: 1.0939\n",
      "Epoch 3: val_accuracy did not improve from 0.63929\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.6109 - loss: 1.0937 - val_accuracy: 0.6325 - val_loss: 1.3030\n",
      "Epoch 4/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.6840 - loss: 0.8740\n",
      "Epoch 4: val_accuracy did not improve from 0.63929\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.6841 - loss: 0.8739 - val_accuracy: 0.6227 - val_loss: 2.3491\n",
      "Epoch 5/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.7867 - loss: 0.6656\n",
      "Epoch 5: val_accuracy improved from 0.63929 to 0.64031, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.7864 - loss: 0.6661 - val_accuracy: 0.6403 - val_loss: 1.7821\n",
      "Epoch 6/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.7738 - loss: 0.6615\n",
      "Epoch 6: val_accuracy improved from 0.64031 to 0.64371, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.7739 - loss: 0.6614 - val_accuracy: 0.6437 - val_loss: 1.5534\n",
      "Epoch 7/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.7783 - loss: 0.6767\n",
      "Epoch 7: val_accuracy did not improve from 0.64371\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.7785 - loss: 0.6761 - val_accuracy: 0.6423 - val_loss: 1.9139\n",
      "Epoch 8/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.8391 - loss: 0.5022\n",
      "Epoch 8: val_accuracy improved from 0.64371 to 0.65524, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8389 - loss: 0.5028 - val_accuracy: 0.6552 - val_loss: 1.0366\n",
      "Epoch 9/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8175 - loss: 0.5870\n",
      "Epoch 9: val_accuracy did not improve from 0.65524\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8174 - loss: 0.5875 - val_accuracy: 0.6366 - val_loss: 1.3595\n",
      "Epoch 10/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8485 - loss: 0.5069\n",
      "Epoch 10: val_accuracy did not improve from 0.65524\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8485 - loss: 0.5070 - val_accuracy: 0.6515 - val_loss: 1.5020\n",
      "Epoch 11/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 23ms/step - accuracy: 0.8881 - loss: 0.3967\n",
      "Epoch 11: val_accuracy did not improve from 0.65524\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.8880 - loss: 0.3970 - val_accuracy: 0.6451 - val_loss: 1.9745\n",
      "Epoch 12/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8657 - loss: 0.4367\n",
      "Epoch 12: val_accuracy improved from 0.65524 to 0.66101, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8657 - loss: 0.4368 - val_accuracy: 0.6610 - val_loss: 1.4600\n",
      "Epoch 13/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8758 - loss: 0.4409\n",
      "Epoch 13: val_accuracy improved from 0.66101 to 0.66203, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8757 - loss: 0.4410 - val_accuracy: 0.6620 - val_loss: 1.1767\n",
      "Epoch 14/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8582 - loss: 0.4624\n",
      "Epoch 14: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8585 - loss: 0.4619 - val_accuracy: 0.6440 - val_loss: 2.0298\n",
      "Epoch 15/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8869 - loss: 0.4004\n",
      "Epoch 15: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8869 - loss: 0.4006 - val_accuracy: 0.6213 - val_loss: 1.1642\n",
      "Epoch 16/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.8959 - loss: 0.3805\n",
      "Epoch 16: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.8959 - loss: 0.3806 - val_accuracy: 0.6542 - val_loss: 1.9938\n",
      "Epoch 17/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9007 - loss: 0.3900\n",
      "Epoch 17: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9007 - loss: 0.3902 - val_accuracy: 0.6539 - val_loss: 1.2021\n",
      "Epoch 18/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.8938 - loss: 0.3835\n",
      "Epoch 18: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 26ms/step - accuracy: 0.8937 - loss: 0.3836 - val_accuracy: 0.6525 - val_loss: 1.0565\n",
      "Epoch 19/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9011 - loss: 0.3828\n",
      "Epoch 19: val_accuracy did not improve from 0.66203\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 26ms/step - accuracy: 0.9011 - loss: 0.3827 - val_accuracy: 0.6522 - val_loss: 2.0381\n",
      "Epoch 20/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9043 - loss: 0.3592\n",
      "Epoch 20: val_accuracy improved from 0.66203 to 0.69121, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9042 - loss: 0.3596 - val_accuracy: 0.6912 - val_loss: 0.9978\n",
      "Epoch 21/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9078 - loss: 0.3573\n",
      "Epoch 21: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9078 - loss: 0.3575 - val_accuracy: 0.6508 - val_loss: 1.0437\n",
      "Epoch 22/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9062 - loss: 0.3753\n",
      "Epoch 22: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9062 - loss: 0.3753 - val_accuracy: 0.6600 - val_loss: 0.9274\n",
      "Epoch 23/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9036 - loss: 0.3494\n",
      "Epoch 23: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9037 - loss: 0.3494 - val_accuracy: 0.6637 - val_loss: 1.0215\n",
      "Epoch 24/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9262 - loss: 0.3352\n",
      "Epoch 24: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9261 - loss: 0.3353 - val_accuracy: 0.6634 - val_loss: 1.0711\n",
      "Epoch 25/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9162 - loss: 0.3515\n",
      "Epoch 25: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9162 - loss: 0.3516 - val_accuracy: 0.6464 - val_loss: 1.5663\n",
      "Epoch 26/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9071 - loss: 0.3636\n",
      "Epoch 26: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9072 - loss: 0.3634 - val_accuracy: 0.6834 - val_loss: 0.7465\n",
      "Epoch 27/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9391 - loss: 0.2843\n",
      "Epoch 27: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9390 - loss: 0.2845 - val_accuracy: 0.6471 - val_loss: 1.3644\n",
      "Epoch 28/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9293 - loss: 0.3174\n",
      "Epoch 28: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9292 - loss: 0.3176 - val_accuracy: 0.6369 - val_loss: 2.5651\n",
      "Epoch 29/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9323 - loss: 0.3159\n",
      "Epoch 29: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9323 - loss: 0.3160 - val_accuracy: 0.6447 - val_loss: 1.1330\n",
      "Epoch 30/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9289 - loss: 0.3332\n",
      "Epoch 30: val_accuracy did not improve from 0.69121\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9290 - loss: 0.3328 - val_accuracy: 0.6447 - val_loss: 1.2202\n",
      "Epoch 31/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9444 - loss: 0.2855\n",
      "Epoch 31: val_accuracy improved from 0.69121 to 0.72379, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9443 - loss: 0.2857 - val_accuracy: 0.7238 - val_loss: 1.2333\n",
      "Epoch 32/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9394 - loss: 0.2915\n",
      "Epoch 32: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9393 - loss: 0.2917 - val_accuracy: 0.6586 - val_loss: 1.0431\n",
      "Epoch 33/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9322 - loss: 0.3326\n",
      "Epoch 33: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9321 - loss: 0.3327 - val_accuracy: 0.6525 - val_loss: 1.0503\n",
      "Epoch 34/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9498 - loss: 0.2769\n",
      "Epoch 34: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9497 - loss: 0.2771 - val_accuracy: 0.6403 - val_loss: 4.2622\n",
      "Epoch 35/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9502 - loss: 0.2711\n",
      "Epoch 35: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9502 - loss: 0.2712 - val_accuracy: 0.6597 - val_loss: 1.0963\n",
      "Epoch 36/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9415 - loss: 0.2926\n",
      "Epoch 36: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9414 - loss: 0.2927 - val_accuracy: 0.6556 - val_loss: 2.3391\n",
      "Epoch 37/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9570 - loss: 0.2589\n",
      "Epoch 37: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9570 - loss: 0.2589 - val_accuracy: 0.6624 - val_loss: 1.2279\n",
      "Epoch 38/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9570 - loss: 0.2531\n",
      "Epoch 38: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9569 - loss: 0.2536 - val_accuracy: 0.6505 - val_loss: 1.6538\n",
      "Epoch 39/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9598 - loss: 0.2596\n",
      "Epoch 39: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9598 - loss: 0.2597 - val_accuracy: 0.6502 - val_loss: 4.4844\n",
      "Epoch 40/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9562 - loss: 0.2523\n",
      "Epoch 40: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9561 - loss: 0.2525 - val_accuracy: 0.6556 - val_loss: 2.7266\n",
      "Epoch 41/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9518 - loss: 0.2647\n",
      "Epoch 41: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9517 - loss: 0.2650 - val_accuracy: 0.6556 - val_loss: 2.8617\n",
      "Epoch 42/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9446 - loss: 0.3101\n",
      "Epoch 42: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9445 - loss: 0.3101 - val_accuracy: 0.6742 - val_loss: 0.9709\n",
      "Epoch 43/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9628 - loss: 0.2479\n",
      "Epoch 43: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9628 - loss: 0.2479 - val_accuracy: 0.6576 - val_loss: 2.6368\n",
      "Epoch 44/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9597 - loss: 0.2620\n",
      "Epoch 44: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9596 - loss: 0.2621 - val_accuracy: 0.6474 - val_loss: 1.5000\n",
      "Epoch 45/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9422 - loss: 0.3021\n",
      "Epoch 45: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 26ms/step - accuracy: 0.9423 - loss: 0.3018 - val_accuracy: 0.6630 - val_loss: 1.2104\n",
      "Epoch 46/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9625 - loss: 0.2478\n",
      "Epoch 46: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9624 - loss: 0.2480 - val_accuracy: 0.6576 - val_loss: 2.0685\n",
      "Epoch 47/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9690 - loss: 0.2272\n",
      "Epoch 47: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9689 - loss: 0.2273 - val_accuracy: 0.6681 - val_loss: 1.5529\n",
      "Epoch 48/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9636 - loss: 0.2472\n",
      "Epoch 48: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9635 - loss: 0.2476 - val_accuracy: 0.6495 - val_loss: 3.6089\n",
      "Epoch 49/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9638 - loss: 0.2536\n",
      "Epoch 49: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9638 - loss: 0.2538 - val_accuracy: 0.6203 - val_loss: 1.6268\n",
      "Epoch 50/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9551 - loss: 0.2831\n",
      "Epoch 50: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9551 - loss: 0.2830 - val_accuracy: 0.6641 - val_loss: 0.8902\n",
      "Epoch 51/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9641 - loss: 0.2508\n",
      "Epoch 51: val_accuracy did not improve from 0.72379\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9641 - loss: 0.2508 - val_accuracy: 0.6410 - val_loss: 1.4373\n",
      "Epoch 52/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9681 - loss: 0.2413\n",
      "Epoch 52: val_accuracy improved from 0.72379 to 0.73838, saving model to /kaggle/working/Model.keras\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9680 - loss: 0.2414 - val_accuracy: 0.7384 - val_loss: 0.9551\n",
      "Epoch 53/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9633 - loss: 0.2548\n",
      "Epoch 53: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9633 - loss: 0.2549 - val_accuracy: 0.6614 - val_loss: 1.1996\n",
      "Epoch 54/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9686 - loss: 0.2400\n",
      "Epoch 54: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9686 - loss: 0.2400 - val_accuracy: 0.6532 - val_loss: 2.8937\n",
      "Epoch 55/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9582 - loss: 0.2865\n",
      "Epoch 55: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9582 - loss: 0.2866 - val_accuracy: 0.6651 - val_loss: 2.3740\n",
      "Epoch 56/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9603 - loss: 0.2711\n",
      "Epoch 56: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9603 - loss: 0.2710 - val_accuracy: 0.6675 - val_loss: 1.4077\n",
      "Epoch 57/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9742 - loss: 0.2239\n",
      "Epoch 57: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9742 - loss: 0.2241 - val_accuracy: 0.6597 - val_loss: 1.7073\n",
      "Epoch 58/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9402 - loss: 0.4303\n",
      "Epoch 58: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9403 - loss: 0.4293 - val_accuracy: 0.6725 - val_loss: 1.2580\n",
      "Epoch 59/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9573 - loss: 0.2727\n",
      "Epoch 59: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9575 - loss: 0.2723 - val_accuracy: 0.6712 - val_loss: 1.0948\n",
      "Epoch 60/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9788 - loss: 0.2152\n",
      "Epoch 60: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9788 - loss: 0.2152 - val_accuracy: 0.6559 - val_loss: 1.3388\n",
      "Epoch 61/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9762 - loss: 0.2208\n",
      "Epoch 61: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9762 - loss: 0.2208 - val_accuracy: 0.6345 - val_loss: 2.5403\n",
      "Epoch 62/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9733 - loss: 0.2335\n",
      "Epoch 62: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9733 - loss: 0.2336 - val_accuracy: 0.6580 - val_loss: 1.5789\n",
      "Epoch 63/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9637 - loss: 0.2568\n",
      "Epoch 63: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9637 - loss: 0.2566 - val_accuracy: 0.7082 - val_loss: 1.2048\n",
      "Epoch 64/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9717 - loss: 0.2454\n",
      "Epoch 64: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9717 - loss: 0.2455 - val_accuracy: 0.6454 - val_loss: 3.1323\n",
      "Epoch 65/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9697 - loss: 0.2389\n",
      "Epoch 65: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9696 - loss: 0.2390 - val_accuracy: 0.6396 - val_loss: 1.9777\n",
      "Epoch 66/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9595 - loss: 0.2686\n",
      "Epoch 66: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9596 - loss: 0.2684 - val_accuracy: 0.6597 - val_loss: 1.2766\n",
      "Epoch 67/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9694 - loss: 0.2534\n",
      "Epoch 67: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9694 - loss: 0.2534 - val_accuracy: 0.6586 - val_loss: 1.7665\n",
      "Epoch 68/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 23ms/step - accuracy: 0.9803 - loss: 0.2164\n",
      "Epoch 68: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9803 - loss: 0.2165 - val_accuracy: 0.6990 - val_loss: 1.1321\n",
      "Epoch 69/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 22ms/step - accuracy: 0.9753 - loss: 0.2288\n",
      "Epoch 69: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9752 - loss: 0.2291 - val_accuracy: 0.6542 - val_loss: 1.5765\n",
      "Epoch 70/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9711 - loss: 0.2380\n",
      "Epoch 70: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9711 - loss: 0.2379 - val_accuracy: 0.6987 - val_loss: 0.8702\n",
      "Epoch 71/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9693 - loss: 0.2328\n",
      "Epoch 71: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 26ms/step - accuracy: 0.9694 - loss: 0.2327 - val_accuracy: 0.6943 - val_loss: 1.1335\n",
      "Epoch 72/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9770 - loss: 0.2207\n",
      "Epoch 72: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9770 - loss: 0.2207 - val_accuracy: 0.6946 - val_loss: 0.9752\n",
      "Epoch 73/1000\n",
      "\u001b[1m228/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 23ms/step - accuracy: 0.9837 - loss: 0.1989\n",
      "Epoch 73: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 28ms/step - accuracy: 0.9836 - loss: 0.1992 - val_accuracy: 0.6597 - val_loss: 3.1787\n",
      "Epoch 74/1000\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9726 - loss: 0.2381\n",
      "Epoch 74: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9726 - loss: 0.2381 - val_accuracy: 0.6702 - val_loss: 1.3547\n",
      "Epoch 75/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9720 - loss: 0.2371\n",
      "Epoch 75: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9720 - loss: 0.2370 - val_accuracy: 0.6949 - val_loss: 1.2285\n",
      "Epoch 76/1000\n",
      "\u001b[1m229/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9760 - loss: 0.2239\n",
      "Epoch 76: val_accuracy did not improve from 0.73838\n",
      "\u001b[1m230/230\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m6s\u001b[0m 27ms/step - accuracy: 0.9759 - loss: 0.2241 - val_accuracy: 0.6820 - val_loss: 1.2847\n",
      "Epoch 76: early stopping\n",
      "Restoring model weights from the end of the best epoch: 26.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.src.callbacks.history.History at 0x7e8b9b705ad0>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(\n",
    "    train_dataset,\n",
    "    validation_data=val_dataset,\n",
    "    epochs=1000,\n",
    "    callbacks=create_callbacks(\"/kaggle/working/logs\", \"/kaggle/working/Model.keras\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "76deab62",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-07-15T05:20:32.341113Z",
     "iopub.status.busy": "2025-07-15T05:20:32.340813Z",
     "iopub.status.idle": "2025-07-15T05:20:34.828627Z",
     "shell.execute_reply": "2025-07-15T05:20:34.827593Z"
    },
    "papermill": {
     "duration": 2.854093,
     "end_time": "2025-07-15T05:20:34.830683",
     "exception": false,
     "start_time": "2025-07-15T05:20:31.976590",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.11/dist-packages/keras/src/trainers/trainer.py:212: UserWarning: Model doesn't support `jit_compile=True`. Proceeding with `jit_compile=False`.\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1m93/93\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m2s\u001b[0m 9ms/step - accuracy: 0.7398 - loss: 0.9298\n",
      "Test Loss: 0.9551, Test Accuracy: 0.7384\n"
     ]
    }
   ],
   "source": [
    "best_model = tf.keras.models.load_model('/kaggle/working/Model.keras')\n",
    "test_loss, test_accuracy = best_model.evaluate(val_dataset)\n",
    "print(f\"Test Loss: {test_loss:.4f}, Test Accuracy: {test_accuracy:.4f}\")"
   ]
  }
 ],
 "metadata": {
  "kaggle": {
   "accelerator": "gpu",
   "dataSources": [
    {
     "datasetId": 1445766,
     "sourceId": 2391312,
     "sourceType": "datasetVersion"
    }
   ],
   "dockerImageVersionId": 31090,
   "isGpuEnabled": true,
   "isInternetEnabled": true,
   "language": "python",
   "sourceType": "notebook"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.13"
  },
  "papermill": {
   "default_parameters": {},
   "duration": 518.706159,
   "end_time": "2025-07-15T05:20:38.243178",
   "environment_variables": {},
   "exception": null,
   "input_path": "__notebook__.ipynb",
   "output_path": "__notebook__.ipynb",
   "parameters": {},
   "start_time": "2025-07-15T05:11:59.537019",
   "version": "2.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
